package com.yiyi.credit.manage.sso.manager.controller;

import com.yiyi.credit.manage.sso.common.Constant;
import com.yiyi.credit.manage.sso.common.exception.ResponseCode;
import com.yiyi.credit.manage.sso.model.dto.response.Response;
import com.yiyi.credit.manage.sso.model.entity.SysUserInfo;
import com.yiyi.credit.manage.sso.service.inner.SysUserInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class SysUserDetailController {

    @Autowired
    SysUserInfoService sysUserInfoService;

    //private static Logger logger = LoggerFactory.getLogger(SysUserDetailController.class);


    @RequestMapping(value = "/getSysUserDetailById")
    public Object getSysUserDetailById(@RequestParam String sysUserId) throws Exception {

        if (StringUtils.isEmpty(sysUserId)) {
            return new Response<>(ResponseCode.NO_SYS_USER);
        }
        SysUserInfo sysUserInfo = sysUserInfoService.getSysUserBySid(Long.parseLong(sysUserId)).get(Constant.INT_ZERO);
        return new Response<>(sysUserInfo);
    }



    @RequestMapping(value = "/updatesysUserDetail")
    public Object updatesysUserDetail(@RequestBody SysUserInfo sysUserInfo) throws Exception {

        if (sysUserInfo == null) {
            return new Response<>(ResponseCode.NO_SYS_USER);
        }

        sysUserInfoService.updateSysUserInfo(sysUserInfo);
        return new Response<>(ResponseCode.SUCCESS);
    }

}



